'use strict';

const {Controller} = require('egg');
const ResponseUtil = require('../utils/ResponseUtil');

class NotifyController extends Controller {

    async getSystemMessageList() {
        let query = this.ctx.query;
        const res = await this.ctx.service.notify.getSystemMessageList(query);
        return this.ctx.body = ResponseUtil.success(res.list, res.total);
    }

    async getSystemMessageDetail(){
        let query = this.ctx.query;
        const res = await this.ctx.service.notify.getSystemMessageDetail(query);
        return this.ctx.body = ResponseUtil.success(res);
    }

    async deleteSystemMessage(){
        let query = this.ctx.query;
        const res = await this.ctx.service.notify.deleteSystemMessage(query);
        return this.ctx.body = ResponseUtil.success(res);
    }

    async addSystemMessage(){
        let body = this.ctx.request.body;
        const res = await this.ctx.service.notify.addSystemMessage(body);
        return this.ctx.body = ResponseUtil.success(res);
    }

    async updateSystemMessage(){
        let body = this.ctx.request.body;
        const res = await this.ctx.service.notify.updateSystemMessage(body);
        return this.ctx.body = ResponseUtil.success(res);
    }
}

module.exports = NotifyController;
